#define SYSTEM_SCHEDULE_CLOCK_SPEED 100
#define system_h
#define reg unsigned long
void keyboard();
void suspend_all();
unsigned char inportb(unsigned short _port);
void outportb(unsigned short _port, unsigned char _data);
void outportw(unsigned short _port,unsigned short _data);
extern unsigned long cpu_eax;
extern unsigned long cpu_ebx;
extern unsigned long cpu_ecx;
extern unsigned long cpu_edx;
extern unsigned long cpu_esp;
extern unsigned long cpu_ebp;
extern unsigned long cpu_esi;
extern unsigned long cpu_edi;
extern unsigned long cpu_cs;
extern unsigned long cpu_ds;
extern unsigned long cpu_ss;
extern unsigned long cpu_fs;
extern unsigned long cpu_gs;
extern unsigned long cpu_es;
extern unsigned long cpu_cr0;
extern unsigned long cpu_cr1;
extern unsigned long cpu_cr2;
extern unsigned long cpu_cr3;
extern unsigned long cpu_espp;
extern unsigned long cpu_eflags;
void getcpu();
void bioscall(unsigned short ax,unsigned short bx,unsigned short cx,unsigned short dx,unsigned short si,unsigned short di,unsigned short no);
int bios(short sax,short sbx,short scx,short sdx,short ssi,short sdi,short intno);
extern unsigned short ax;
extern unsigned short bx;
extern unsigned short cx;
extern unsigned short dx;
extern unsigned short si;
extern unsigned short di;
extern unsigned short f;
extern unsigned long eax;
extern unsigned long ebx;
extern unsigned long ecx;
extern unsigned long edx;
extern unsigned long esi;
extern unsigned long edi;
void __cpu(void);
#define start_of_interrupt()						\
	({	asm("pusha");	\
	})


#define end_of_interrupt()						\
	({	asm("popa");	\
		asm("leave");	\
		asm("iret");			\
	})

reg read_cr0();
void write_cr0(reg);
reg read_cr3();
void write_cr3(reg);
void timer();
void set_page_directory_base(reg);
void enable_pg();


struct CPU_state	{
	unsigned long eax;
	unsigned long ebx;
	unsigned long ecx;
	unsigned long edx;
	unsigned long esi;
	unsigned long edi;
	unsigned long fs;
	unsigned long gs;
	unsigned long es;
	unsigned long ds;
	unsigned long esp;
	unsigned long ebp;
	unsigned long flags;
};

typedef struct CPU_state CPU_state;

#define NAMEL 20
#define MAXPIPES 8

struct processstate	{
	CPU_state cpustate;
	int sleep_state;
	int sleep_count;
	void *entry_fn;
	void *idle_timer;
	unsigned long stack;
	unsigned long tmout;
	char process_name[NAMEL];
	unsigned long process_id;
	struct pipe *pipehandle[MAXPIPES];	//Maximum acquirable pipe handles. (To be changed to linked list later on)
	struct processstate *next;
};

struct pipe **get_pipe(unsigned long pid);
